import type { App } from 'vue';
import { ElLoading, ElScrollbar, ElButton } from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import ElementPlus from 'element-plus';

export const setupElementPlus = (app: App<Element>) => {
  // 设置 Element Plus 语言为中文
  app.use(ElementPlus, { locale: zhCn });

  const plugins = [ElLoading];
  const components = [ElScrollbar, ElButton];

  // 注册插件
  plugins.forEach((plugin) => {
    app.use(plugin);
  });

  // 注册组件
  components.forEach((component) => {
    if (component.name) { // 确保 component.name 是有效字符串
      app.component(component.name, component);
    }
  });
};
